package cn.lg.soar.core.config;

import cn.lg.soar.core.util.RunnerShowInfo;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@EnableSwagger2
@Configuration
@ConditionalOnProperty(name = "lg.swagger.enabled", havingValue = "true")
public class SoarSwaggerConfigurer extends SwaggerConfigurerBase{

    @Bean
    public Docket soar(){
        return new Docket(DOCUMENTATION_TYPE)
                .apiInfo(this.apiInfo())
                .groupName("soar")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.lg.soar"))
                .paths(PathSelectors.any())
                .build();
    }

    public SoarSwaggerConfigurer() {
        RunnerShowInfo.showUrl("Swagger 文档", "/doc.html");
    }

}
